var app = angular.module('app',[]).controller('index',
		function($scope, $http){
	$scope.bs=0

	setInterval(() => {
		if ($scope.bs >= 2) {
			$scope.bs = 0;
		} else {
			$scope.bs+=1;
		}
		var slicks = $(".slick");
		for (var i=0, j=slicks.length; i<j; i++) {
			var slide = $(".slick")[i];
			if (i == $scope.bs) {
				$(slide).addClass("slick-active");
			} else {
				$(slide).removeClass("slick-active");
			}
		}
		
		$scope.$apply();
	}, 3000)
	var getBikesMsg = function() {
		
		$http.post("./getBikes").success(function(data){
		
		    $scope.bike = [];
		    for (var i=0,j=data.length;i<j;i++){
		    	var bikeMsg = data[i];
		    	$scope.bike.push(bikeMsg);
		    	
		    }
			
		})
	}
	getBikesMsg();
	
	var getSessionUser = function(){ 
		
		   $http.post("./getSessionUser").success(function(data){
			 
			   $scope.username = data.username;
			 
		   })
		} 
	getSessionUser();
	
	$scope.logout = function(){
    	
    	$http.post("./logout1").success(function(data) {
    		if(data.status == "ok"){
				window.open("./userlogin");
			}
    		
    	})
    }
})
